#include "superheader.h"
#include "ChannelSwitching/channelSwitching.h"
#include "MessageSwitching/messageSwitching.h"
#include "PacketSwitching/packetSwitching.h"

int main()
{
  QFile         resultFile;
  QString       nameFile("../bin/dataSwitching_%1.dat");
  QTextStream   stream(&resultFile);
  QList<double> listIntensities;
  QList<double> listMaxPacketSize;

  listIntensities << 0.0001 << 0.001 << 0.01 << 0.03 << 0.05
                  << 0.06   << 0.07  << 0.08 << 0.09 << 0.1;
  listMaxPacketSize << 0.01 << 0.1 << 0.5 << 2.0;

  foreach (double maxPacketSize, listMaxPacketSize) {
    resultFile.setFileName( nameFile.arg(maxPacketSize) );
    resultFile.open(QIODevice::WriteOnly | QIODevice::Text);
    stream << "\"ТП=" << maxPacketSize << "\"\t\"КК\"\t\"КС\"\t\"КП\"\n";

    cout << "\t\tТП = " << maxPacketSize << endl;
    cout << "\t\t--\n";
    networkSettings.timePacketSwitching = maxPacketSize;
    foreach (double intensity, listIntensities) {
      cout << "\n\t\tИнтенсивность = " << intensity << endl;
      inputData.intensity = intensity;
      networkSettings.init(inputData);

      stream << "\"" << intensity << "\"";

      cout << "-> Коммутация каналов:\n";
      stream << "\t" << channelSwitchingDelay();

      cout << "-> Коммутация сообщений:\n";
      stream << "\t" << messageSwitchingDelay();

      cout << "-> Коммутация пакетов:\n";
      stream << "\t" << packetSwitchingDelay() << endl;

      cout << endl;
    }

    resultFile.close();
  }

  return 0;
}
